rust-numpy
Rust bindings for the NumPy C-API
API documentation
Requirements
- Rust 1.39+
- Some Rust libraries
- ndarray for rust-side matrix library
- pyo3 for cpython binding
- and more (see Cargo.toml)
- numpy installed in your python environments (e.g., via
pip install numpy
)- We recommend
numpy >= 1.16.0
, though older version may work.
- We recommend
Note Starting from 0.3, rust-numpy migrated from rust-cpython to pyo3. If you want to use rust-cpython, use version 0.2.1 from crates.io.
Supported Python version
Currently 3.5, 3.6, 3.7, and 3.8 are supported.
Python2 Support
Version 0.5.0 is the last version that supports Python2.
If you want to compile this library with Python2, please use 0.5.0 from crates.io.
In addition, you have to add a feature flag in Cargo.toml
like
[]
= "0.5.0"
= ["python2"]
.
You can also automatically specify python version in setup.py, using setuptools-rust.
Example
Execute a Python program from Rust and get results
[]
= "numpy-test"
[]
= "0.12"
= "0.12"
use PyArray1;
use ;
use IntoPyDict;
Write a Python module in Rust
Please see the examples directory for a complete example
[]
= "rust_ext"
= ["cdylib"]
[]
= "0.12"
= "0.13"
[]
= "0.12"
= ["extension-module"]
use ;
use ;
use ;
Contribution
We need your feedback.
Don't hesitate to open issues!